#-*- coding: utf-8 -*
#@author 小测试
#@create 2020-03-03 22:23
import requests
import json
class GetMethod:
    """
    二次封装POST,GET,PUT请求
    """
    def __init__(self):
        requests.packages.urllib3.disable_warnings()
    def post_method(self,url,data,header=None):
        #
        res = None
        if header !=None:
            res = requests.post(url=url,data=data,headers=header,verify=False)
        else:
            res = requests.post(url=url,data=data,verify=False)
        return res.json()

    def get_method(self,url,data=None,header=None):
        res = None
        if header !=None:
            res = requests.get(url=url,data=data,headers=header,verify=False)
        else:
            res = requests.get(url=url,data=data,verify=False)
        return res.json()
    def put_method(self,url,data=None,header=None,):
        res = None
        if header !=None:
            res = requests.put(url=url,data=data,headers=header,verify=False)
        else:
            res = requests.put(url=url,data=data,verify=False)
        return res.json()
    def run_method(self,method,url,data=None,header=None):
        res = None
        if method == 'POST':
            res = self.post_method(url,data,header)
        elif method == 'PUT':
            res=self.put_method(url,data,header)
        else:
            res = self.get_method(url,data,header)
        return res
